package com.nil.codegen.base;

import com.nil.codegen.bean.ResponseResult;

/**
 * Controller 基类
 */
public class BaseController {


    public ResponseResult success(Object data) {
        return new ResponseResult(200, "success", data);
    }

    public  ResponseResult success() {
        return new ResponseResult(200, "success", null);
    }

    public ResponseResult success(String msg) {
        return new ResponseResult(200, msg, null);
    }

    public ResponseResult error(String msg) {
        return new ResponseResult(500, msg, null);
    }


    public ResponseResult ofBool(Boolean b) {
        return b ? success(null) : error("操作失败");
    }

    public ResponseResult ofBool(Boolean b, String msg) {
        return b ? success(null) : error(msg);
    }

}
